@extends('layout.admin')
@section('title',"新增管理员")
@section('content')

    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" >
        <div class="col-md-12" id="content" >
            <div class="app_content_div" id="app_content_div_301Index">
                <h3>新增管理员</h3>
            </div>
            <form class="form-horizontal"  method="post" action="/adm/user_create">
                <input name="_token" type="hidden" value="yGxSZQb1HbdqtaIIEvCPqN4VJU3q8Oz9ZZdGclH9">
                <div class="form-group">
                    <label for="username" class="col-sm-2 control-label"><span style="color:red;">*</span>用户名</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" style="width:300px;" id="name" name="name" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="username" class="col-sm-2 control-label"><span style="color:red;">*</span>邮箱</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" style="width:300px;" id="email" name="email" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="password" class="col-sm-2 control-label"><span style="color:red;">*</span>密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control" style="width:300px;" id="password" name="password" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="password_confirmation" class="col-sm-2 control-label"><span style="color:red;">*</span>确认密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control" style="width:300px;" id="password_confirmation" name="password_confirmation" >
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" onclick="check()" class="btn btn-default">确定</button>

                    </div>
                </div>
            </form>
    <script>
        function check() {
            var name = $("#name").val();
            var email = $("#email").val();
            var password = $("#password").val();
            var password_confirmation = $("#password_confirmation").val();
            var token = "{{csrf_token()}}";
            $.post(
                '/adm/user_create',
                {
                    'name': name,
                    'email': email,
                    'password': password,
                    'password_confirmation': password_confirmation,
                    '_token': token
                },
                function (data)
                {
                    if (data.success)
                    {
                        alert("新用户已成功创建");
                        location.href="/adm/list";
                    }
                    else
                    {
                        alert(data.msg);
                    }
                }, 'json'
            );
        }
    </script>

@endsection

